<?php
exit('used');
require dirname(__file__) . '/core/core.php';
$Eleanor = Eleanor::getInstance();

require dirname(__FILE__) . '/iss.php';

$iss = new plgContentIssuu;

//[issuu layout=http%3A%2F%2Fskin.issuu.com%2Fv%2Flight%2Flayout.xml showflipbtn=true documentid=101218191638-0c5d4307a1b54463b17d9a414da9144f docname=obd-anatomia username=autodiagnostika loadinginfotext=OBD-Anatomia showhtmllink=true width=420 height=272 unit=px]

//exit('used');
//require dirname(__file__) . '/core/core.php';
//$Eleanor = Eleanor::getInstance();
$R = Eleanor::$Db->Query(
	'SELECT `id`, `title`, `announcement`, `text` FROM `el_news_l` WHERE `lcats` = ",2," ORDER BY `ldate` DESC'
);
$Eleanor->Editor_Result->type = 'tinymce';
while ($a = $R->fetch_assoc()) {
	$lan = 'russian';
//	$text = $Eleanor->Editor_result->DownloadImage($a['text'], $a['id']);
//	$text = $iss->issuu_parser($a['text']);
//	if (mb_strpos($text, 'ā') !== false) {
//		$lan = 'latvian';
//	} elseif (mb_strpos($text, 'а') !== false) {
//		$lan = 'russian';
//	} elseif (mb_strpos($text, 'a') !== false) {
//		$lan = 'english';
//	}

	Eleanor::$Db->Update(
		'el_news_l',
		array(
			'title' => trim($a['title']),
			'announcement' => $Eleanor->Editor_result->GetHtml(
				$iss->issuu_parser($a['announcement']),
				true
			),
			'text' => $Eleanor->Editor_result->GetHtml(
				$Eleanor->Editor_result->DownloadImage($a['text'], $a['id']),
				true
			),
			'language' => $lan
		),
		'id=' . $a['id'] . ' LIMIT 1'
	);
}